<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<jsp:include page="global.jsp"></jsp:include>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>任务信息</title>
</head>
<body>
<div class="easyui-tabs" style="width:100%;height:490px;">
	<div title="当前任务" style="padding:2px">
		<table class="easyui-datagrid" id="projectTaskdg" data-options="
				rownumbers:true,
				singleSelect: true,
				toolbar: '#projectTasktb',
				singleSelect:true,
				pagination:true,
				fit:true,
				fitColumns:true,
				pageList:[20,25,30,35,40,45,50],
				pageSize:20">
			<thead>
				<tr>
					<th data-options="field:'projectName',width:80,align:'center'">项目</th>
					<th data-options="field:'projectTaskTypeName',width:80,align:'center'">任务类型</th>
					<th data-options="field:'taskDescription',width:200">任务描述</th>
					<th data-options="field:'taskBeginDate',width:100,align:'center'">计划开始日期</th>
					<th data-options="field:'planFinishDate',width:100,align:'center'">计划完成日期</th>
					<th data-options="field:'actualFinishDate',width:100,align:'center'">实际完成日期</th>
					<th data-options="field:'id',width:50,align:'center',formatter:projectTasktbFormatControl">查看</th>
				</tr>
			</thead>
		</table>
		<div id="projectTasktb" style="height:auto">
			<div>
				项目名称:
				<select data-options="editable: false" id = "project" class="easyui-combobox">
					<option value = "-1"> --全部-- </option>
					<c:forEach var="item" items="${projects }" >
						<option value = "${item.id }">${item.name }</option>
					</c:forEach>
				</select>
				<a href="javascript:projectTaskSearch()" class="easyui-linkbutton" iconCls="icon-search">查 找</a>
			</div>
		</div>
			
		
	</div>
	<div title="历史任务" style="padding:2px;">
		
		<table class="easyui-datagrid" id="previousProjectTaskdg" data-options="
				rownumbers:true,
				singleSelect: true,
				toolbar: '#previousProjectTasktb',
				singleSelect:true,
				pagination:true,
				fit:true,
				fitColumns:true,
				pageList:[20,25,30,35,40,45,50],
				pageSize:20">
			<thead>
				<tr>
					<th data-options="field:'projectName',width:80,align:'center'">项目</th>
					<th data-options="field:'projectTaskTypeName',width:80,align:'center'">任务类型</th>
					<th data-options="field:'taskDescription',width:200">任务描述</th>
					<th data-options="field:'taskBeginDate',width:100,align:'center'">计划开始日期</th>
					<th data-options="field:'planFinishDate',width:100,align:'center'">计划完成日期</th>
					<th data-options="field:'actualFinishDate',width:100,align:'center'">实际完成日期</th>
					<th data-options="field:'id',width:50,align:'center',formatter:previousProjectTasktbFormatControl">查看</th>
				</tr>
			</thead>
		</table>
		<div id="previousProjectTasktb" style="height:auto">
			<div>
				项目名称:
				<select data-options="editable: false" id = "project" class="easyui-combobox">
					<option value = "-1"> --全部-- </option>
					<c:forEach var="item" items="${projects }" >
						<option value = "${item.id }">${item.name }</option>
					</c:forEach>
				</select>
				<a href="javascript:previousProjectTaskSearch()" class="easyui-linkbutton" iconCls="icon-search">查 找</a>
			</div>
		</div>

	</div>

	<div title="未来任务" style="padding:2px;">

		<table class="easyui-datagrid" id="futureProjectTaskdg" data-options="
				rownumbers:true,
				singleSelect: true,
				toolbar: '#futureProjectTasktb',
				singleSelect:true,
				pagination:true,
				fit:true,
				fitColumns:true,
				pageList:[20,25,30,35,40,45,50],
				pageSize:20">
			<thead>
				<tr>
					<th data-options="field:'projectName',width:80,align:'center'">项目</th>
					<th data-options="field:'projectTaskTypeName',width:80,align:'center'">任务类型</th>
					<th data-options="field:'taskDescription',width:200">任务描述</th>
					<th data-options="field:'taskBeginDate',width:100,align:'center'">计划开始日期</th>
					<th data-options="field:'planFinishDate',width:100,align:'center'">计划完成日期</th>
					<th data-options="field:'actualFinishDate',width:100,align:'center'">实际完成日期</th>
					<th data-options="field:'id',width:50,align:'center',formatter:futureProjectTasktbFormatControl">查看</th>
				</tr>
			</thead>
		</table>
		<div id="futureProjectTasktb" style="height:auto">
			<div>
				项目名称:
				<select data-options="editable: false" id = "project" class="easyui-combobox">
					<option value = "-1"> --全部-- </option>
					<c:forEach var="item" items="${projects }" >
						<option value = "${item.id }">${item.name }</option>
					</c:forEach>
				</select>
				<a href="javascript:futureProjectTaskSearch()" class="easyui-linkbutton" iconCls="icon-search">查 找</a>
			</div>
		</div>
		
	</div>

</div>


<div id="projectTaskLookDetail" class="easyui-window" title="任务详情" data-options="modal:true,closed:true,iconCls:'icon-search'" style="width:720px; height:400px;padding:5px;">
		<div class="easyui-layout" data-options="fit:true">
			<div data-options="region:'center'" style="padding:10px;">
				<table width="100%" height="100%">
					<tr>
						<td width="120px;" align="right">项目名称：</td>
						<td>
							<input class="easyui-textbox" id="lookProjectId" readonly="readonly" style="width: 200px;" />
						</td>
						<td width="120px;" align="right">分配人：</td>
						<td>
							<input class="easyui-textbox" id="lookTaskCreatorName" readonly="readonly" style="width: 200px;" />
						</td>
					</tr>
					<tr>
						<td align="right">任务类型：</td>
						<td>
							<input class="easyui-textbox" id="lookProjectTaskTypeId" data-options="required:true" readonly="readonly" style="width: 200px;" />
						</td>
						<td align="right">状态：</td>
						<td>
							<input class="easyui-textbox" id="lookStatus" data-options="required:true" readonly="readonly" style="width: 200px;" />
						</td>
					</tr>
					<tr>
						<td align="right">任务描述：</td>
						<td colspan="3">
							<input class="easyui-textbox" data-options="multiline:true" style="width: 550px; height: 80px;" id="lookTaskDescription" readonly="readonly">
						</td>
					</tr>
					<tr>
						<td align="right">任务领取日期：</td>
						<td>
							<input class="easyui-datebox" id="lookTaskBeginDate" readonly="readonly" style="width: 200px;" />
						</td>
						<td align="right">初次计划完成日期：</td>
						<td>
							<input class="easyui-datebox" id="lookFirstPlanFinishDate" readonly="readonly" style="width: 200px;" />
						</td>
					</tr>
					<tr>
						<td align="right">计划完成日期：</td>
						<td>
							<input class="easyui-datebox" id="lookPlanFinishDate" readonly="readonly" style="width: 200px;" />
						</td>
						<td align="right">实际完成日期：</td>
						<td>
							<input class="easyui-datebox" id="lookActualFinishDate" readonly="readonly" style="width: 200px;" />
						</td>
					</tr>
					<tr>
						<td align="right">计划工时数：</td>
						<td>
							<input class="easyui-textbox" id="lookPlanWorktime" readonly="readonly" style="width: 200px;" />
						</td>
						<td align="right">实际工时数：</td>
						<td>
							<input class="easyui-textbox" id="lookActualWorktime" readonly="readonly" style="width: 200px;" />
						</td>
					</tr>
					<tr>
						<td colspan="4">
							计划完成日期变更次数：
							<input class="easyui-textbox" id="lookPlanFinishDateChangeCount" readonly="readonly" />
						</td>
					</tr>
				</table>
			</div>
			<div data-options="region:'south',border:false" style="text-align:right;padding:5px 0 0;">
				<a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onclick="javascript:$('#projectTaskLookDetail').window('close')" style="width:80px">关 闭</a>
			</div>
		</div>
	</div>
	
<script type="text/javascript">
	function projectTaskSearch(){
		var projectId = $("#project").combobox("getValue");
		var url = "queryMiltStatusProjetTasks?peopleId=${people.id}&status=0055&status=0100&status=0200&projectId=" + projectId;
		$("#projectTaskdg").datagrid('reload', url);
	}
	function previousProjectTasktbFormatControl(val, row){
		return '<a class="ctl" href="javascript:void(0)" onclick="projectTaskLookDetail(' + val + ')">任务详情</a>';
	}
	function previousProjectTaskSearch(){
		var projectId = $("#project").combobox("getValue");
		var url = "queryMiltStatusProjetTasks?peopleId=${people.id}&status=3000&projectId=" + projectId;
		
		$("#previousProjectTaskdg").datagrid('reload', url);
	}
	
	function projectTasktbFormatControl(val, row){
		return '<a class="ctl" href="javascript:void(0)" onclick="projectTaskLookDetail(' + val + ')">任务详情</a>';
	}
	
	function futureProjectTasktbFormatControl(val, row){
		return '<a class="ctl" href="javascript:void(0)" onclick="projectTaskLookDetail(' + val + ')">任务详情</a>';
	}
	function futureProjectTaskSearch(){
		var projectId = $("#project").combobox("getValue");
		var url = "queryProjectTaskPerson?peopleId=${people.id}&status=0001&projectId=" + projectId;
		$("#futureProjectTaskdg").datagrid('reload', url);
	}
	
	
	function projectTaskLookDetail(id){
		var params = "id=" + id;
		$.ajax({
		  type: "GET",
		  url: "findProjectTaskPerson",
		  data: params,
		  success:function(data){
			  	var val = $.parseJSON(data);
				if(val.success){
					var item = val.data;

					$("#lookPlanFinishDateChangeCount").textbox("setValue", item.planFinishDateChangeCount + "");
					$("#lookProjectId").textbox("setValue", item.projectName);
					$("#lookTaskCreatorName").textbox("setValue", item.taskCreatorName);
					$("#lookProjectTaskTypeId").textbox("setValue", item.projectTaskTypeName);
					$("#lookTaskCreateTime").textbox("setValue", item.taskCreateTime);
					$("#lookActualFinishDate").textbox("setValue", item.actualFinishDate);
					$("#lookTaskBeginDate").textbox("setValue", item.taskBeginDate);
					$("#lookFirstPlanFinishDate").textbox("setValue", item.firstPlanFinishDate);
					$("#lookPlanFinishDate").textbox("setValue", item.planFinishDate);
					$("#lookTaskAcceptTime").textbox("setValue", item.taskAcceptTime);
					$("#lookTaskDescription").textbox("setValue", item.taskDescription);
					$("#lookPlanWorktime").textbox("setValue", item.planWorktime);
					$("#lookActualWorktime").textbox("setValue", item.actualWorktime);
					$("#lookStatus").textbox("setValue", item.status);
					
					$('#projectTaskLookDetail').window('open');
				}else{
					$.messager.alert("提示", val.msg, "error");
				}
		  	}
		});
	}
	
	$(function(){
		previousProjectTaskSearch();
		projectTaskSearch();
		futureProjectTaskSearch();
	});
</script>
</body>
</html>